package com.authine.cloudpivot.ext.service.bill;

import com.authine.cloudpivot.ext.dto.model.bill.Bill;
import com.authine.cloudpivot.ext.dto.model.bill.OrderToBill;
import com.authine.cloudpivot.ext.dto.query.BillQuery;
import com.authine.cloudpivot.ext.service.invoice.InvoiceApplyService;
import com.authine.cloudpivot.ext.service.invoice.impl.InvoiceApplyServiceImpl;
import com.authine.cloudpivot.ext.service.settle.SettleService;
import com.authine.cloudpivot.ext.service.settle.impl.SettleServiceImpl;
import com.authine.cloudpivot.ext.service.trade.TradeService;
import com.authine.cloudpivot.ext.service.trade.impl.TradeServiceImpl;

import java.util.Collection;
import java.util.List;

public interface BillService {
    TradeService tradeService = new TradeServiceImpl();
    InvoiceApplyService invoiceApplyService = new InvoiceApplyServiceImpl();
    SettleService settleService = new SettleServiceImpl();

    /**
     * 删除补差账单
     *
     * @param ids 账单ID
     */
    void delete(Collection<String> ids);

    /**
     * 获取账单数据，通过Actual参数判断是否要减掉退货退款和退服务费部分
     * @param query
     * @return
     */
    List<Bill> list(BillQuery query);

    /**
     * 根据结算明细ID删除服务费账单
     *
     * @param ids referenceIds 关联的付款明细ID
     */
    void deleteService(Collection<String> ids);

    /**
     * 创建商品账单
     * @param bills
     */
    void createGoodsBill(Collection<OrderToBill> bills);

    /**
     *
     * @param bills
     */
    void createRefundGoodsBill(Collection<Bill> bills);

    /**
     * 创建服务费账单
     * @param serviceBills
     * @return 账单ID
     */
    List<String> createServiceBill(List<Bill> serviceBills);

    /**
     * 创建补差账单
     * @param balanceBills
     * @return
     */
    List<String> createBlanceBill(List<Bill> balanceBills);

    /**
     * 申请规则验证，业务类型、业务方向必须一致，账单类型必须只能是商品和增补或平台费和金融费
     *
     * @param bills     账单列表
     * @param verifyOrg 是否验证组织唯一
     */
    void applyRuleValid(List<Bill> bills, boolean verifyOrg);

    /**
     * 获取服务费账单
     * @return
     */
    List<Bill> listServiceFee(BillQuery query);
}
